


*************************************************
**Version July 2022
*************************************************

clear all

use "C:\Users\Chiara\Dropbox (Personale)\CHIARA\LAVORI IN CORSO\RICERCA\IQfertility\Data\Chiara\DatTrueCouples.dta" 

************* Female iff sex==1; Male iff sex==0 ***************************
gsort Codice_coppia
order sessione Cod_ind Codice_coppia  TrueCouple sex  Male Female zIntention IntPartner Raven  RavenPartner Ravent scenario scenarioPartner /*
*/Occupation OccupationPartner civils civilsPartner Age AgePartner infer SOEPrisk Education EducationPartner country Income IncomePartner childrenb childrenbPartner 

*exit

keep if scenario==0
 
 
********************************************************************************
**************************  MAIN TEXT TABLES ***********************************
********************************************************************************


********************************************************************************
******************** Descriptive Statistics of the two countries sample ********
******************************************************************************** 

replace College=1 if edu=="laurea magistrale / specialistica"
*Non standardized variables  
bys country sex: sum Q1 Raven College Occupation Age childrenb civils sti infer Q22
* Standardized variables 
bys country sex: sum zIntention zRaven Occupation Age childrenb Income civils infer SOEPrisk
bys country: sum zRaven

bys country sex: sum College
bys country sex: sum sti
bys country sex: sum Q22

bys country: tab  College sex, col nof
bys country: tab  Occupation sex, col nof
bys country: tab  civils sex, col nof



********************************************************************************
**  Distribution of intention variable
********************************************************************************

bys country sex: sum zIntention


********************************************************************************
**  Correlation of intention and fluid intelligence
********************************************************************************

pwcorr zRaven zIntention, star(.05)

*******************************************************************************
** Analysis of the role of Intelligence 
********************************************************************************			   
* Table 1 and Table 2 (column 1)
bys sex: reg zIntention zRaven 


* Table 1 and Table 2 (column 2)
bys sex: reg zIntention zRaven i.College

* Table 1 and Table 2 (column 3)
 
bys sex: reg zIntention zRaven i.College i.Occupation i.OccupationPartner i.civils Age AgePartner ///
               Income IncomePartner i.childrenb i.infer SOEPrisk i.country, robus cluster (Codice_coppia)

* Table 3 (all columns)			   
bys country sex: reg zIntention zRaven i.College i.Occupation i.OccupationPartner i.civils Age AgePartner ///
               Income IncomePartner i.childrenb i.infer SOEPrisk i.country, robus cluster (Codice_coppia) 		   
			   

bys country sex: reg zIntention zRaven i.College i.Occupation i.OccupationPartner i.civils Age AgePartner ///
               Income IncomePartner i.childrenb i.infer SOEPrisk i.country, robus cluster (Codice_coppia)
			   
	

* Table 4
sum zRaven, detail 
 
gen     HighRaven=1 if zRaven>=.2135 
replace HighRaven=0 if zRaven<.2135  

*reg zIntention zRaven College Age AgeRaven OneChild TwoChildren MoreTwoChildren MarriedCU Cohab zIncome zIncomePartner SOEPrisk if Female==1, robus cluster (Codice_coppia) 

reg zIntention agecat##HighRaven if Female==1 & country==1
margins agecat#HighRaven
marginsplot, legend(off) ytitle(Fertility Intentions) xtitle(Age) title("Fertility Intention: Women, Italy") caption("Blue Line: Low IQ")
*graph export  "$pathOutputPenTalFigs/FertByAgeIQ_Italy_NoSc.png",  replace

reg zIntention agecat##HighRaven if Female==1 & country==2
margins agecat#HighRaven
marginsplot, legend(off) ytitle(Fertility Intentions) xtitle(Age) title("Fertility Intention: Women, Norway") caption("Blue Line: Low IQ")
*graph export  "$pathOutputPenTalFigs/FertByAgeIQ_Norway_NoSc.png",  replace

gen AgezRaven=Age*zRaven 

gen AgeRaven=Age*Raven 

 
reg zIntention  Age  AgezRaven if Female==1 & country==1, robus cluster (Codice_coppia)
reg zIntention  Age  AgezRaven if Female==1 & country==2, robus cluster (Codice_coppia)
 
 